package com.finstone.data.spider.eshop.service.impl;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import us.codecraft.webmagic.Request;
import us.codecraft.webmagic.Spider;

import com.finstone.data.spider.eshop.pipeline.EShopGoodsPipline;
import com.finstone.data.spider.eshop.processor.EShopGoodsProcessor;
import com.finstone.data.spider.eshop.service.AbstractSpiderService;

@Component
public class EShopGoodsService extends AbstractSpiderService<String> {

	@Autowired
	private EShopGoodsProcessor eShopGoodsProcessor;

	@Autowired
	private EShopGoodsPipline eShopGoodsPipline;

	@Override
	@PostConstruct
	public void init() {
		spider = Spider.create(eShopGoodsProcessor).addPipeline(eShopGoodsPipline).thread(5);
	}

	@Override
	protected void doPutTask(String url) {
		Request request  = new Request(url);
		spider.addRequest(request);
	}
}
